<div id="ECS_ORDERTOTAL">
<table width="100%" align="center" border="0" cellpadding="5" cellspacing="0" class="ORDERTOTAL" >
  
  <?php if ($_SESSION['user_id'] > 0 && ( $this->_var['config']['use_integral'] || $this->_var['config']['use_bonus'] )): ?>
  <tr style="display:none;">
    <td align="center" bgcolor="#ffffff" class="c_000" >
    <?php echo $this->_var['lang']['complete_acquisition']; ?>
    <?php if ($this->_var['config']['use_integral']): ?>
    <?php echo $this->_var['total']['will_get_integral']; ?> <?php echo $this->_var['points_name']; ?>
    <?php endif; ?>
  </td>
  </tr>
  <?php endif; ?>

  
  <tr class="goods_price_formated">
    <td class="left">商品总价</td>
    <td class="right"><span id='goods_price'><?php echo $this->_var['total']['goods_price_formated']; ?></span></td>
  </tr>

  
  <tr class="shipping_fee_formated">
    <td class="left">运费</td>
    <td class="right" id="shipping_fee"><?php echo $this->_var['total']['shipping_fee_formated']; ?></td>
  </tr>

  
  <tr class="amount_formated">
    <td class="left">订单总价</td>
    <td class="right"><span id='amount_formated'><?php echo $this->_var['total']['amount_formated']; ?></span></td>
  </tr>

  <tr style="display:none;">
    <td align="center" bgcolor="#ffffff" class="c_000">
      <?php echo $this->_var['lang']['goods_all_price']; ?>: <?php echo $this->_var['total']['goods_price_formated']; ?>
      <?php if ($this->_var['total']['pay_fee'] > 0): ?>
      + <?php echo $this->_var['lang']['pay_fee']; ?>: <?php echo $this->_var['total']['pay_fee_formated']; ?>
      <?php endif; ?>
    </td>
  </tr>

  <tr style="display:none;">
    <td align="center" class="pay_money" class="c_000"> 应付: <?php echo $this->_var['total']['amount_formated']; ?>
    <?php if ($this->_var['is_group_buy']): ?><br />
    <?php echo $this->_var['lang']['notice_gb_order_amount']; ?><?php endif; ?>
    <?php if ($this->_var['total']['exchange_integral']): ?><br />
	  <?php echo $this->_var['lang']['notice_eg_integral']; ?><font class="f4_b" style="font-size: 30px; color: #d02857;"><?php echo $this->_var['total']['exchange_integral']; ?></font>
	  <?php endif; ?>
	  </td>
  </tr>

</table>
</div>


<div id="coupon">
  <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" >

  <?php $_from = $this->_var['coupon']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'coupon_son');if (count($_from)):
    foreach ($_from AS $this->_var['coupon_son']):
?>
    <tr class="packet_mail coupon_list">
      <td class="coupon_id" onclick="check_coupon(this);">
        <input class="none" type="checkbox" name="coupon_id" value="<?php echo $this->_var['coupon_son']['coupon_id']; ?>">
        <input type="hidden" class="coupon_id" value="">
      </td>
      <td class="coupon_name"><?php echo $this->_var['coupon_son']['coupon_name']; ?>: <?php if ($this->_var['coupon_son']['is_free'] == 1): ?>运费<?php else: ?>总金额<?php endif; ?>-￥<?php echo $this->_var['coupon_son']['discount']; ?></td>
    </tr>
  <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>


<!--     <tr class="discount_coupon coupon_list">
      <td class="coupon_id" onclick="check_coupon(this);">
        <input class="none" type="checkbox" name="coupon_id[]" value="">
        <input type="hidden" class="coupon_id" value="">
      </td>
      <td class="coupon_name">八折优惠券: 总金额-￥5.00</td>
    </tr> -->
  </table>
</div>
<script>
  /* 选择优惠券 */
  function check_coupon(obj){
    /* 判断勾选状态 */
    if(!$(obj).hasClass("select")){
      $(obj).addClass("select");
      $(obj).children().attr("checked",true);
    }else{
      $(obj).removeClass("select");
      $(obj).children().attr("checked",false);
    }

    var coupon_id = new Array;
    $("input[name=coupon_id]").each(function() {
        if ($(this).attr("checked")) {
            coupon_id.push($(this).val());
        }
    });
    order.Info.CouponId = coupon_id;
    order.Cost();

  }
</script>


<?php if (! $this->_var['area_id'] || ! $this->_var['consignee']['address_id'] || $this->_var['total']['is_stockout']): ?>
  <div class="no_buy">
    提交订单
  </div>
  <?php if (! $this->_var['area_id']): ?>
  <div class="red">该区域不支持配送</div>
  <?php endif; ?>
  <?php if (! $this->_var['consignee']['address_id']): ?>
  <div class="red">请选择收货地址</div>
  <?php endif; ?>
  <?php if ($this->_var['total']['is_stockout']): ?>
  <div class="red">有部分商品已缺货</div>
  <?php endif; ?>
  <a href="flow.php" class="sub" style="display:block;">返回购物车</a>
<?php else: ?>
<?php if ($this->_var['is_gift_start'] == 1): ?>
  <?php if ($this->_var['is_gift'] == 0): ?>
  <div id="gift">
    <div class="gift_list">
          <div class="title" >满100送50,满300送150,满500送300,再购<?php echo $this->_var['nex_price']; ?>元即可获得赠品</div>
    </div>
  </div>
  <?php endif; ?>
  <?php if ($this->_var['is_gift'] == 1): ?>
  <div id="gift">
    <div class="gift_list">
          <div class="title" >赠品已赠完</div>
    </div>
  </div>
  <?php endif; ?>
  <?php if ($this->_var['gift_list']): ?>
  <div id="gift">
      <div class="gift_list">
      <?php if ($this->_var['rank'] >= 1): ?><div class="title" onclick="change_gift(1);">满100送50，请点击选择任意一套画材大礼包</div><?php endif; ?>
      <?php if ($this->_var['rank'] >= 2): ?><div class="title" onclick="change_gift(2);">满300送150，请点击选择任意一套画材大礼包</div><?php endif; ?>
      <?php if ($this->_var['rank'] >= 3): ?><div class="title" onclick="change_gift(3);">满500送300，请点击选择任意一套画材大礼包</div><?php endif; ?>
          <div class="son_box">
            <?php $_from = $this->_var['gift_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'gift');if (count($_from)):
    foreach ($_from AS $this->_var['gift']):
?>
                <?php if ($this->_var['gift']['stock'] <= 0): ?>
                <div class="no_stock gift_<?php echo $this->_var['gift']['rank']; ?> <?php if ($this->_var['gift']['rank'] != $this->_var['rank']): ?> none<?php endif; ?>" >
                <input type="hidden" class="parent_id" value="<?php echo $this->_var['gift']['parent_id']; ?>">
                  <div class="name">
                    <?php echo $this->_var['gift']['name']; ?>
                  </div>
                  <div class="price">
                    已赠完 <br>
                  </div>
                </div>
                <?php else: ?>
                  <div class="son gift_<?php echo $this->_var['gift']['rank']; ?> <?php if ($this->_var['gift']['rank'] != $this->_var['rank']): ?> none<?php endif; ?>" onclick="add_gift(this);">
                <input type="hidden" class="parent_id" value="<?php echo $this->_var['gift']['parent_id']; ?>">
                  <div class="name">
                    <?php echo $this->_var['gift']['name']; ?>
                  </div>
                  <div class="price">
                    正品市场价 <br>
                    <span class="font18">￥<?php echo $this->_var['gift']['price']; ?></span>
                  </div>
                </div>
                <?php endif; ?>
            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
          </div>


     </div>
  </div>
  <script>
  function add_gift (obj) {
    $(obj).siblings('.son').hide();
    $('.son').removeClass('son_now');
    $(obj).addClass('son_now');
    $(obj).siblings('.no_stock').hide();
    var parent_id = $(obj).find('.parent_id').val();
    $("#gift_id").val(parent_id);
  }



  function change_gift(id){
    $('.son').hide();
    $('.no_stock').hide();
    $('.gift_'+id).show();
  }
  </script>
  <input type="hidden" id="gift_id" value ="0">
  <?php endif; ?>
<?php endif; ?>








  <div class="sub_bottom">
    <div class="left">
      <span class="text">应付款金额：</span>
      <span class="price" id="amount"><?php echo $this->_var['total']['amount_formated']; ?></span>
    </div>
    <div class="right">
      <div class="sub" onclick="order.SumbitOrder();">
        提交订单
      </div>
    </div>
  </div>
  <script>
  order.Info.Rid      = '<?php echo $this->_var['rid']; ?>';
  order.Info.Message   =  $('#postscript').val();
  order.Info.PayId     =  $('#payment').val();
  order.Info.AddressId =  $('#AddressId').val();

  </script>




<?php endif; ?>


